package org.jmc.refmanager.web.wicket.form;

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.PropertyModel;

/**
 *
 */
public abstract class ServiceSearchForm extends Form<String> {
	private static final long serialVersionUID = 1L;

	private String codePostal;
	private String codeUO;
	private String libCourt;
	private String libLong;

	protected abstract void onSubmit(PageParameters params);

	/**
	 * @param id
	 */
	public ServiceSearchForm(String id) {
		super(id);
		add(new TextField<String>("libCourt",
					new PropertyModel<String>(this, "libCourt")));
		add(new TextField<String>("codePostal",
					new PropertyModel<String>(this, "codePostal")));
		add(new TextField<String>("libLong",
					new PropertyModel<String>(this, "libLong")));
		add(new TextField<String>("codeUO",
					new PropertyModel<String>(this, "codeUO")));

//		final FeedbackPanel feedback = new FeedbackPanel("feedback");
//		feedback.setOutputMarkupId(true);
//		add(feedback);
		
		Button btnSearch = new Button("btnSearch") {
			private static final long serialVersionUID = 1L;

			@Override
			public void onSubmit() {
				// TODO
			}
		};
		add(btnSearch);
		
//		Button btnCancel = new Button("btnCancel") {
//			private static final long serialVersionUID = 1L;
//			@Override
//			public void onSubmit() {
//				// TODO
//			}
//		}.setDefaultFormProcessing(false);
//		add(btnCancel);
	}

	@Override
	protected void onSubmit() {
		PageParameters params = new PageParameters();
		params.add("libCourt", getLibCourt());
		params.add("codePostal", getCodePostal());
		params.add("libLong", getLibLong());
		params.add("codeUO", getCodeUO());
		this.onSubmit(params);
	}

	/**
	 * @return the codePostal
	 */
	public String getCodePostal() {
		return codePostal;
	}

	/**
	 * @return the libCourt
	 */
	public String getLibCourt() {
		return libCourt;
	}

	/**
	 * @return the codeUO
	 */
	public String getCodeUO() {
		return codeUO;
	}

	/**
	 * @return the libLong
	 */
	public String getLibLong() {
		return libLong;
	}

}
